package org.example.util;

import java.util.List;

public class AlarmUtil {
    //从高位到低位存告警编号和类型
    public static String[] alarmNo={"Reserved12","Reserved11","Reserved10"  ,"Reserved9",  //31 30 29 28
                                    "Reserved8","Reserved7","Reserved6"  ,"Reserved5",  //27 26 25 24
                                    "Reserved4","Reserved3","BMSLidOpenAlarm"  ,"OutOfFenceAlarm",  //23 22 21 20
                                    "OfflineAlarm","IdleAlarm","Reserved2"  ,"MosTempHighAlarm" ,  //19 18 17 16
                                    "ShortCurAlarm","DischargeTempLowAlarm","DischargeTempHighAlarm"  ,"ChargeTempLowAlarm",  //15 14 13 12
                                    "ChargeTempHighAlarm","Reserved1","CellVolDiffAlarm"  ,"SocAlarm"   ,  //11 10  9  8
                                    "ChargeOvercurAlarm"   ,"DischargeOvercurAlarm"   ,"EnvTempLowAlarm","EnvTempHighAlarm",//7 6 5 4
                                    "SingleVolHighAlarm","SingleVolLowAlarm","TotalVolHighAlarm","TotalVolLowAlarm"//3 2 1 0
                                     };
    public static String[] alarmName={"Reserved12","Reserved11","Reserved10"  ,"Reserved9",  //31 30 29 28
                                      "Reserved8","Reserved7","Reserved6"  ,"Reserved5",  //27 26 25 24
                                      "Reserved4","Reserved3","BMS开盖告警"  ,"超出电子围栏告警",  //23 22 21 20
                                      "BMS离线告警","BMS闲置告警","Reserved2"  ,"BMS MOS高温告警",  //19 18 17 16
                                      "BMS短路告警","BMS放电低温告警","BMS放电高温告警"  ,"BMS充电低温告警",  //15 14 13 12
                                      "BMS充电高温告警","Reserved1"      ,"BMS压差过大告警"  ,"BMS SOC低告警"   ,  //11 10  9  8
                                      "BMS充电过流告警"   ,"BMS放电过流告警"   ,"BMS环境低温告警","BMS环境高温告警",//7 6 5 4
                                      "BMS单体过压告警","BMS单体欠压告警","BMS总压过高告警","BMS总压过低告警"//3 2 1 0
                                        };
    public static int[] getAlarmBit(int alarm){
        String s=Integer.toBinaryString(alarm);
        char[] c=s.toCharArray();
        int[] binary=new int[c.length];
        System.out.println();
        for(int i=0;i<c.length;i++){
            binary[i] = Integer.parseInt(String.valueOf(c[i]));
//            System.out.print(binary[i]);
        }
        return binary;
    }
}
